package org.gas.barapraja.db.dao;

import javax.annotation.PostConstruct;

import org.gas.barapraja.db.entity.Account;
import org.gas.barapraja.db.entity.Token;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class InMemoryGasDb {
	
	@Autowired
	private AccountDao accountDao;
	
	@PostConstruct
	public void populateData(){
		createAccount();
	}
	
	private void createAccount(){
		Account account=new Account();
		account.setSystemId("system001");
		account.setCompanyName("company 1");
		account.setPassword("pass1");
		account.setCompanyNumber("0856671112");
		Token token=new Token();
		token.setTokenValue(100);
		account.setToken(token);
		accountDao.persist(account);
		
		Account account2=new Account();
		account2.setSystemId("system002");
		account2.setCompanyName("company 2");
		account2.setPassword("pass2");
		account2.setCompanyNumber("0856671113");
		Token token2=new Token();
		token2.setTokenValue(70);
		account2.setToken(token2);
		accountDao.persist(account2);
		
		Account account3=new Account();
		account3.setSystemId("system003");
		account3.setCompanyName("company 3");
		account3.setPassword("pass3");
		account3.setCompanyNumber("082131211");
		Token token3=new Token();
		token3.setTokenValue(312);
		account3.setToken(token3);
		accountDao.persist(account3);
		
	}

}
